How to stop using console.log() and start using your browser’s debugger
主要转载至此文,标题有引战意味。正如评论第一的所说,断点能加速开发过程调试,但是我觉得console.log()
在生产环境中更为有用,二者没有优劣之分,根据不同的代码选择不同的方法即可。
To open Chrome Developer Tools, press Command+Option+I (Mac) or Control+Shift+I (Linux).
![](http://pic.sunnyfu.cn/18-11-8/38882649.jpg)
A breakpoint is something that your browser looks for in order to know when to pause execution of your code and allow you the opportunity to debug it.
![](http://pic.sunnyfu.cn/18-11-8/73809658.jpg)
![](http://pic.sunnyfu.cn/18-11-8/15811544.jpg)
To define values to ‘watch’, click on the watch pane at the very top and click the + symbol once it opens. Here, you can type in variable names or other expressions.
![](http://pic.sunnyfu.cn/18-11-8/67366701.jpg)